<?php

include("header.php");

	print("
		<title>DoD Block Exploits - Server List</title>

		<table align=\"center\" cellpadding=\"4\" cellspacing=\"0\" rules=\"rows\">
		<tr height=\"25px\">
		<td align=\"center\" style=\"background: #20578d\">IP Address</td>
		<td align=\"center\" style=\"background: #20578d\">Name</td>
		<td align=\"center\" style=\"background: #20578d\">Last Contact</td>
		<td align=\"center\" style=\"background: #20578d\">Plugin Version</td>
		</tr>
		");


	$svrData = array();
	$versNum = $_GET["version"];
   
	if(isset($versNum))
		$query = "select id,ip,name,lastcontact,version from ".$tbl_servers." WHERE version='".$versNum."' order by lastcontact desc";
	else
		$query = "select id,ip,name,lastcontact,version from ".$tbl_servers." order by lastcontact desc";
		
	$result = mysql_query($query);
	
	if($result)
		$num_results = mysql_num_rows($result);
	else
		$num_results = 0;
		
	if($num_results<1)
		{
		print("
			<tr class=\"row0\" onMouseOver=\"this.className='rowhover'\" onMouseOut=\"this.className='row0'\" onClick=\"document.location='view_servers.php'\">
			<td colspan=\"4\" class=\"customtd1\" align=\"center\">No Servers Found".$versNum."</td>
			</tr>
		</tr>");
		}
	else
		{
		for($i=0;$row = mysql_fetch_array($result);$i++)
			{
			for($j=0;$j<5;$j++)
				{
				$svrData[$i][$j] = $row[$j];
				}
			}
        
		$rowclass = 0;
		for($i=0;$svrData[$i][0]!=null;$i++)
			{
			$diff=$time_diff * 3600;
			$logtime=date("m-d-Y",strtotime($svrData[$i][3]) + $diff);

			print("			
				<tr class=\"row".$rowclass."\" onMouseOver=\"this.className='rowhover'\" onMouseOut=\"this.className='row".$rowclass."'\" onClick=\"document.location='view_details_server.php?ip=".$svrData[$i][1]."'\">
					<td class=\"customtd1\" align=\"center\">".$svrData[$i][1]."</td>
					<td class=\"customtd1\" align=\"center\">".$svrData[$i][2]."</td>
					<td class=\"customtd1\" align=\"center\">".$logtime."</td>
					<td class=\"customtd1\" align=\"center\">".$svrData[$i][4]."</td>
				</tr>");
			 
			 $rowclass = 1 - $rowclass;	 
			}
		}
			
	if(isset($versNum))
		{
		$query = "SELECT COUNT(id) AS 'total' FROM ".$tbl_servers." WHERE version='".$versNum."'";
		$result = mysql_query($query);
        
		if($result)
			$server_num = mysql_fetch_array($result);
		else
			$server_num['total'] = 0;
		
		print("
			<tr>
			<td align=\"center\" colspan=\"4\" height=\"25px\" style=\"background: #20578d\">* dislaying ".$server_num['total']." servers that have run version ".$versNum." *
			</td>
			</tr> 
			");
		}
	else
		{
		$query = "SELECT COUNT(id) AS 'total' FROM ".$tbl_servers."";
		$result = mysql_query($query);
        
		if($result)
			$server_num = mysql_fetch_array($result);
		else
			$server_num['total'] = 0;
			
		print("
			<tr>
			<td align=\"center\" colspan=\"4\" height=\"25px\" style=\"background: #20578d\">* dislaying ".$server_num['total']." servers that have run the SQL version *
			</td>
			</tr> 
			");
		}

include("footer.php");

?>